<?php

require_once ($cfgPaths['lib'].'cms/postprocessors/cmsPostProcessor_latex.o.inc.php');

class cmsPostProcessor_pnglatex extends cmsPostProcessor_latex
{
  function cmsPostProcessor_pnglatex ($conf)
  {
    parent::cmsPostProcessor_latex($conf);
  }
  
  function process ($str)
  {
    chdir($GLOBALS['cfgPaths']['cacheDir']);
    $fn = 'tmp'.$GLOBALS['doc_id'];
    $fp = fopen($fn.'.tex',"w");
    fputs($fp,$str);
    fclose($fp);
    exec('latex '.$fn.'.tex');
    exec('dvips '.$fn.'.dvi');
    exec('ps2png '.$fn.'.ps '.$fn.'.png');
    $file = join('',file($fn.'.png'));
    syn_unlink($fn.'.tex');
    syn_unlink($fn.'.dvi');
    syn_unlink($fn.'.ps');
    syn_unlink($fn.'.aux');
    syn_unlink($fn.'.log');
    syn_unlink($fn.'.png');
    chdir('..');
    return $file;
  }
    
}


?>